home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _scropen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-19  |  3.9 KB  |  128 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #ifdef UNIX
  4. #include <defs.h>
  5. #include <term.h>
  6. #undef lines
  7. #endif
  8.  
  9. #ifdef PDCDEBUG
  10. char *rcsid__scropen = "$Header: C:\CURSES\private\RCS\_scropen.c 2.1 1993/06/18 20:22:59 MH Rel MH $";
  11. #endif
  12.  
  13.  
  14.  
  15.  
  16. /*man-start*********************************************************************
  17.  
  18.   PDC_scr_open()    - Internal low-level binding to open the physical screen
  19.  
  20.   PDCurses Description:
  21.      This function provides a low-level binding for the Flexos
  22.      platform which must open the screen before writing to it.
  23.  
  24.      This function is provided in order to access the FlexOS 16 bit
  25.      character set for input rather than the limited input
  26.      character set associated with the VT52.
  27.  
  28.   PDCurses Return Value:
  29.      This function returns OK on success, otherwise an ERR is returned.
  30.  
  31.   PDCurses Errors:
  32.      The DOS platform will never fail.  The Flexos platform may fail
  33.      depending on the ability to open the current virtual console in
  34.      8 (as opposed to 16) bit mode.
  35.  
  36.   Portability:
  37.      PDCurses    int    PDC_scr_open( SCREEN* internal, bool echo );
  38.  
  39. **man-end**********************************************************************/
  40.  
  41. int    PDC_scr_open(SCREEN *internal, bool echo)
  42. {
  43.  
  44. #ifdef PDCDEBUG
  45.     if (trace_on) PDC_debug("PDC_scr_open() - called\n");
  46. #endif
  47.  
  48. #ifdef    FLEXOS
  49.     retcode = s_get(T_VIRCON, 0L, (char *) &vir, (long) sizeof(vir));
  50.     if (retcode < 0L)
  51.         return( ERR );
  52.  
  53.     kbmode = vir.vc_kbmode;
  54.     cmode = vir.vc_mode;
  55.     vir.vc_mode = 0;
  56.  
  57.     if (!echo)    vir.vc_kbmode |= VCKM_NECHO;
  58.     else        vir.vc_kbmode &= ~VCKM_NECHO;
  59.  
  60.     smode = vir.vc_smode;
  61.     retcode = s_set(T_VIRCON, 0L, (char *) &vir, (long) sizeof(vir));
  62.     if  (retcode < 0L)
  63.         return( ERR );
  64.  
  65.     if (vir.vc_type & 0x03)    internal->mono = TRUE;
  66.     else            internal->mono = FALSE;
  67.  
  68.     internal->orig_attr = vir.vc_flcolor | vir.vc_blcolor;
  69.     _flexos_16bitmode();
  70. #endif
  71.  
  72. #ifdef    DOS
  73.     internal->orig_attr     = 0;
  74.     internal->orig_emulation = getdosmembyte (0x487);
  75. #endif
  76.  
  77. #ifdef    OS2
  78.     internal->orig_attr     = 0;
  79.     internal->orig_emulation = 0;
  80. #endif
  81.  
  82. #ifdef UNIX
  83.     PDC_get_cursor_pos(&internal->cursrow, &internal->curscol);
  84.     internal->autocr    = FALSE;        /* lf -> crlf by default      */
  85.     internal->raw_out    = FALSE;    /* tty I/O modes          */
  86.     internal->raw_inp    = FALSE;    /* tty I/O modes          */
  87.     internal->cbreak    = FALSE;
  88.     internal->echo        = echo;
  89.     internal->refrbrk    = FALSE;    /* no premature end of refresh*/
  90.     internal->visible_cursor= TRUE;        /* Assume that it is visible  */
  91.     internal->cursor    = 0;
  92.     internal->font        = 0;
  93.     internal->lines        = PDC_get_rows();
  94.     internal->cols        = PDC_get_columns();
  95.     internal->audible    = TRUE;
  96.     internal->direct_video    = FALSE;        /* Assume that we can          */
  97.     internal->adapter    = PDC_query_adapter_type();
  98.     _CUR_TERM.prog_mode.c_iflag &= ~(ICRNL);
  99.     _CUR_TERM.prog_mode.c_oflag &= ~(ONLCR|OPOST);
  100.     _CUR_TERM.prog_mode.c_lflag &= ~(ICANON|ECHO);
  101.     _CUR_TERM.prog_mode.c_cc[VMIN] = 1;
  102.     ioctl(_CUR_TERM.fd, TCSETA, &_CUR_TERM.prog_mode);
  103. #else
  104.     PDC_get_cursor_pos(&internal->cursrow, &internal->curscol);
  105.     internal->autocr    = TRUE;        /* lf -> crlf by default      */
  106.     internal->raw_out    = FALSE;    /* tty I/O modes          */
  107.     internal->raw_inp    = FALSE;    /* tty I/O modes          */
  108.     internal->cbreak    = FALSE;
  109.     internal->echo        = echo;
  110.     internal->refrbrk    = FALSE;    /* no premature end of refresh*/
  111. #if !defined OS2
  112.     internal->video_seg    = 0xb000;    /* Base screen segment addr   */
  113.     internal->video_ofs    = 0x0;        /* Base screen segment ofs    */
  114. #endif
  115.     internal->video_page    = 0;        /* Current Video Page          */
  116.     internal->direct_video    = TRUE;        /* Assume that we can          */
  117.     internal->visible_cursor= TRUE;        /* Assume that it is visible  */
  118.     internal->cursor    = PDC_get_cursor_mode();
  119.     internal->adapter    = PDC_query_adapter_type();
  120.     internal->font        = PDC_get_font();
  121.     internal->scrnmode    = PDC_get_scrn_mode();
  122.     internal->lines        = PDC_get_rows();
  123.     internal->cols        = PDC_get_columns();
  124.     internal->audible    = TRUE;
  125. #endif
  126.     return( OK );
  127. }
  128.